Repository navigation
test(service-automation): witness parallel fan-out structurally, not by a wall-clock bound - #19804
Merged
huangyiirene merged 1 commit intoSep 23, 2026
Merged
Conversation
…by clock The parallel-branches case graded a real `Date.now()` window against a fixed 100 ms bound, which is wrong in both directions at once: the sequential path it claims to rule out (two 10 ms branches, measured 23 ms here) fits well inside the bound, so the assertion stays green through the very regression it documents; and because the graded quantity is real elapsed time (measured 13 ms here), a contended runner reddens a correct parallel engine. Parallelism is observable structurally. The registered executor now records an enter/exit trace of the branch bodies, and the case asserts that everything preceding the first branch return is a branch ENTRY — true exactly when both bodies are in flight at once. A sequentialised fan-out traces `enter:branch_a, exit:branch_a, …` and fails at any runner speed; no clock is read and no bound is chosen, so runner speed cannot reach the assertion. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AhQASwqJr2Z7XfGWUdvnbF
Contributor
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
huangyiirene
marked this pull request as ready for review
September 23, 2026 07:18
huangyiirene
deleted the
claude/issue-19766-parallel-branches-wallclock
branch
September 23, 2026 07:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19766
Clause-②: no
The parallel-branches case in
packages/services/service-automation/src/engine.test.tsgraded a realDate.now()window against a fixed 100 ms bound. This replaces that with a structural witness of the property — what the engine did, in what order — so the case can fail on the regression it names and cannot fail on runner speed.Premise verified at
origin/mainfirst (both halves true, measured)Base
fae870352e. Both halves were measured, not argued, by lowering the bound to 1 ms throughscripts/ablation-replace.mjsand reading the actual value vitest prints.expected 13 to be less than 1⇒ 13 msexpected 23 to be less than 1⇒ 23 msawait Promise.all(parallelTasks)replaced by afor … await this.executeNode(…)loop, the whole original case still passed:engine.execute, or on one scheduling stall of 87 ms. The bound sits above BOTH the parallel and the sequential path, which is why it separates nothing.The fix
The registered executor — the observable this case already owned — now records an enter/exit trace of the branch bodies, and the case asserts:
Everything preceding the FIRST branch return is a branch ENTRY, and both entries are there — true exactly when both bodies are in flight at once, which is what makes the fan-out parallel.
expect(elapsed).toBeLessThan(100)and itsDate.now()pair are gone; the case is not skipped, renamed, quarantined or weakened, and the flow fixture is untouched.Evidence direction 1 — it fires
Deliberate regression: the unconditional fan-out in
packages/services/service-automation/src/engine.tsruns one branch at a time.Restore proven byte-exact by the same tool, on the absolute path, against HEAD rather than the index:
git status --porcelainafter the run printed nothing. The mutation needed no rebuild to be read:engine.test.tsimports./engine.js, a package-local specifier vitest resolves tosrc/engine.ts, so nodist/sits between the mutation and the assertion.Evidence direction 2 — runner speed cannot reach it
Argued from the assertion's shape, which is the stronger of the two forms the card allows:
Date.now(), noperformance.now(), no duration, no bound, no timeout of its own.awaitsuspends, not by how long a suspension lasts.delaycan only stretch the wait between that branch's own entry and its own exit. It cannot move an entry across a sibling's return: underPromise.allover eagerly created tasks, both bodies are entered before either is awaited, on any machine, at any load.enter:branch_a, exit:branch_a, …whatever the delays are.Observed green while the box was also running this repo's shared verify lock and sibling agent work:
Local verification
pnpm --filter '@objectstack/service-automation^...' build --concurrency=2pnpm --filter @objectstack/service-automation testpnpm --filter @objectstack/service-automation typechecktsc --noEmit+check:test-typecheck, 0 errors)node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, all 53 run, reconciled with--ranpnpm lint(eslint . --no-inline-config, whole repo, not narrowed)The two NOT MEASURED are
pnpm check:dual-build-cjs-loadsandpnpm check:type-check-debt: both exited 3,PREREQUISITE NOT MET— each reads built output for the whole workspace and refused to measure without it. That is neither a pass nor a finding; CI builds the workspace and runs them there. Reconciliation:53 derived, 51 run, 2 NOT-MEASURED, 0 UNRUN.Changeset routing
skip-changeset, ⛔ not an empty changeset. The diff is one test file, and this package publishesfiles: ["dist","README.md","CHANGELOG.md"]. Probed on the freshly built bundles, with a positive control:A symbol introduced by this diff appears zero times in every shipped artefact while the control symbol hits; nothing published moves, so there is no release note to write.
Acceptance notes
Out of scope here, reported to the PM rather than filed:
expect(elapsed)has zero hits underpackages/services/service-automation/src.git grep -n "expect(elapsed)" -- 'packages/**/*.test.ts'returns 10 hits in other packages. Most separate orders of magnitude (1 s against a 60 s acquire timeout, 2 s against a 5 s request), where the bound does discriminate. The one that shares this card's second defect ispackages/plugins/plugin-webhooks/src/auto-enqueuer.test.ts:558,expect(elapsed).toBeLessThan(20)— a correct implementation reddens on a contended runner. Unlike this card's assertion it is not a phantom in the other direction: the regression it rules out would await a promise nothing resolves, so it hangs into the 5 s test timeout rather than passing. Not reproducible today, so it is noted, not filed.packages/services/service-automation/src/builtin/template-date-offset-dst.test.ts— the real origin of the red this card was filed beside, per the filer's own correction — was ⛔ not touched: that is [finding] service-automation's DST-offset test timed out at the default 5000 ms on a contended runner and reddened an unrelated PR — each cell switches process.env.TZ, and the whole file's tests took 27 s against 498 s of import #19768, held serial behind this one.Generated by Claude Code